package com.bawei.module_goods.repository

import com.bawei.lib_net.RetrofitFactory
import com.bawei.module_goods.network.GoodsApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn

class GoodsDetailRepository {
    val api: GoodsApi
    init {
        api= RetrofitFactory.getRetrofitFactory().create(GoodsApi::class.java)
    }

    suspend fun getGoodsDetail(goodsId:Int)= flow {
        emit(api.getGoodsDetail(goodsId))
    }.flowOn(Dispatchers.IO)
    suspend fun getDetailComment(goodsId:Int,pageNum: Int,pageSize:Int)= flow {
        emit(api.getDetailComment(goodsId,pageNum,pageSize))
    }.flowOn(Dispatchers.IO)
}